package org.apache.jsp;

import javax.servlet.*;
import javax.servlet.http.*;
import javax.servlet.jsp.*;
import java.io.*;
import java.util.*;
import beans.BeanLugares;
import utils.GeneradorXML;
import mapping.ElementoMapa;

public final class insertalugar_jsp extends org.apache.jasper.runtime.HttpJspBase
    implements org.apache.jasper.runtime.JspSourceDependent {

  private static final JspFactory _jspxFactory = JspFactory.getDefaultFactory();

  private static java.util.List _jspx_dependants;

  private javax.el.ExpressionFactory _el_expressionfactory;
  private org.apache.AnnotationProcessor _jsp_annotationprocessor;

  public Object getDependants() {
    return _jspx_dependants;
  }

  public void _jspInit() {
    _el_expressionfactory = _jspxFactory.getJspApplicationContext(getServletConfig().getServletContext()).getExpressionFactory();
    _jsp_annotationprocessor = (org.apache.AnnotationProcessor) getServletConfig().getServletContext().getAttribute(org.apache.AnnotationProcessor.class.getName());
  }

  public void _jspDestroy() {
  }

  public void _jspService(HttpServletRequest request, HttpServletResponse response)
        throws java.io.IOException, ServletException {

    PageContext pageContext = null;
    HttpSession session = null;
    ServletContext application = null;
    ServletConfig config = null;
    JspWriter out = null;
    Object page = this;
    JspWriter _jspx_out = null;
    PageContext _jspx_page_context = null;


    try {
      response.setContentType("text/html; charset=UTF-8");
      pageContext = _jspxFactory.getPageContext(this, request, response,
      			"error/errorpage.jsp", true, 8192, true);
      _jspx_page_context = pageContext;
      application = pageContext.getServletContext();
      config = pageContext.getServletConfig();
      session = pageContext.getSession();
      out = pageContext.getOut();
      _jspx_out = out;

      out.write('\n');
      out.write('\n');
      beans.BeanLugares mybean = null;
      synchronized (_jspx_page_context) {
        mybean = (beans.BeanLugares) _jspx_page_context.getAttribute("mybean", PageContext.PAGE_SCOPE);
        if (mybean == null){
          mybean = new beans.BeanLugares();
          _jspx_page_context.setAttribute("mybean", mybean, PageContext.PAGE_SCOPE);
        }
      }
      out.write("\n");
      out.write("<html xmlns=\"http://www.w3.org/1999/xhtml\">\n");
      out.write("<head>\n");
      out.write("\t<meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\"/>\n");
      out.write("  \t<link rel=\"stylesheet\" href=\"estilos/callejerostyle.css\" type=\"text/css\" media=\"screen\" charset=\"utf-8\" />\n");
      out.write("  \t<script src=\"http://www.google.com/jsapi?key=ABQIAAAAW6ZkayH6hhgMyC2y6LQx8xQkRs_WW3LuT_BxsclnnM2SXBs4HxSp2Ukg-tY3gZU6rw7kePxNiNAS9Q\" type=\"text/javascript\"></script>\n");
      out.write("  \t<script src=\"http://maps.google.com/maps?file=api&amp;v=2&amp;key=ABQIAAAAW6ZkayH6hhgMyC2y6LQx8xTlOAjHTmgj9z0QOzdQFV7VnifGuxSJsOzr3eQromRGXbLCHJKjeEnNNw\" type=\"text/javascript\"></script> \n");
      out.write("  \t<script src=\"js/googlemaps.js\" type=\"text/javascript\" charset=\"utf-8\"></script>\n");
      out.write("  \t<script src=\"ajax/ajax_lugares.js\" type=\"text/javascript\" charset=\"utf-8\"></script>\n");
      out.write("  \t<script src=\"ajax/ajax_login.js\" type=\"text/javascript\" charset=\"utf-8\"></script>\n");
      out.write("</head>\n");
      out.write("\n");
      out.write("<body onload=\"ocultaOpcionesAdmin(); inicializa();ocultar('form_nuevo_lugar');\" onunload=\"GUnload()\">\n");
      out.write("\t");

	Integer ea = (Integer)session.getAttribute("es_admin");
	//A partir del booleano de es_admin podemos cargar unas u otras opciuones que se 
	//muestren al usuario en funcion del rol que desempe�e
	//if(ea!=null){
		//if(ea.intValue()==1){
      out.write("\n");
      out.write("\t\t\t");
      org.apache.jasper.runtime.JspRuntimeLibrary.include(request, response, "cabecera_admin.jsp", out, false);
      out.write("\n");
      out.write("\t\t\t");
      org.apache.jasper.runtime.JspRuntimeLibrary.include(request, response, "menu_admin.html", out, false);
      out.write("\t\n");
      out.write("\t\t");
//}else{
      out.write("\n");
      out.write("\t\t\t<!--<jspinclude page= \"cabecera_user.jsp\"/>\n");
      out.write("\t\t\t<jspinclude page= \"menu_user.html\"/>-->\n");
      out.write("\t\t");
//}
	//} 
	//else{
	//	throw new IllegalArgumentException("Oye! No intentes acceder a esta pagina sin haberte logueado antes.<br>"+ 
	//	"Si ya te logueaste es posible que tu sesion haya expirado; en ese caso, vuelve a introducir tu usuario y contrase&ntilde;a");
	//}
	
      out.write("\n");
      out.write("<div id=\"contenido\">\n");
      out.write("\t<div id = \"capaBusqGmaps\">\n");
      out.write("\t\t<p>Buscar en el mapa:</p>\n");
      out.write("\t\t\t<form action=\"#\" onsubmit=\"showAddress(this.direccion.value, true); return false\">\n");
      out.write("\t\t\t\t<input type=\"text\" id=\"direccion\" name=\"direccion\" size=\"20\" \n");
      out.write("\t\t\t\t\ttitle=\"Introduce lugar o direccion a buscar\"\n");
      out.write("\t\t\t\t\tonfocus =\"rastrearTecla=false;\" onblur=\"rastrearTecla=true;\"/>\n");
      out.write("\t\t\t\t<input type=\"submit\" value=\"Buscar!\" style = \"align:right\" title=\"Pulsa para buscar\"/>\n");
      out.write("\t\t\t</form>\n");
      out.write("\t\t<div id=\"capaCreaMarcador\" onclick=\"ponerMarcadorNuevoLugarEnCentroMapa()\"><p>Poner marcador</p></div>\n");
      out.write("\t</div>\n");
      out.write("\t\t\n");
      out.write("\t<div id=\"form_nuevo_lugar\">\n");
      out.write("\t\t<h2 class=\"titform\">Datos de nuevo lugar de inter&eacute;s</h2>\n");
      out.write("\t\t<hr class=\"hrmarron\" color=\"#cc6600\">\n");
      out.write("\t\t<br/>\n");
      out.write("\t\t<form name=\"frmnuevolugar\" id=\"frmnuevolugar\" method = \"POST\" ENCTYPE=\"multipart/form-data\" onsubmit=\"return false\">\n");
      out.write("\t\t<div>\n");
      out.write("\t\t\t<input type=\"text\" id = \"latitud\" name=\"latitud\" id=\"latitud\" readonly/>\n");
      out.write("\t\t\t<input type=\"text\" id = \"longitud\" name=\"longitud\" id=\"longitud\" readonly/>\n");
      out.write("\t\t</div>\n");
      out.write("\t\t<br/>\n");
      out.write("\t\t<div>\n");
      out.write("\t\t\t<div id=\"itnomlugar\">\n");
      out.write("\t\t\t\t<label for=\"nomlugar\">Nombre<sup>*</sup></label>\n");
      out.write("\t\t\t\t<input type=\"text\" maxlength = \"100\" size=\"35\" id=\"nomlugar\" name=\"nomlugar\" title=\"Introduzca el nombre del lugar\">\n");
      out.write("\t\t\t</div>\n");
      out.write("\t\t\t\t\n");
      out.write("\t\t\t<div id=\"seltipolugar\">\n");
      out.write("\t\t\t\t<label for=\"tipolugar\">Tipo</label>\n");
      out.write("\t\t\t\t<select id=\"tipo_nuevo_lugar\" name=\"tipo_nuevo_lugar\" size=\"1\" title=\"Selecciona el tipo de lugar\">\n");
      out.write("\t\t\t\t");
	
				mybean.conectar();
				List listaTipoLugares = mybean.getTipoLugares();
				Iterator it = listaTipoLugares.iterator();			
				while(it.hasNext()){
					String [] valorTipo = ((String) it.next()).split(",");
				
      out.write("\n");
      out.write("\t\t\t\t\t<option value = \"");
      out.print(valorTipo[0]);
      out.write('"');
      out.write('>');
      out.print(valorTipo[1]);
      out.write("</option>\n");
      out.write("\t\t\t\t");
}
				mybean.desconectar();
				
      out.write("\n");
      out.write("\t\t\t\t</select>\n");
      out.write("\t\t\t</div>\n");
      out.write("\t\t\t\n");
      out.write("\t\t\t<div id=\"itdirecclugar\">\n");
      out.write("\t\t\t\t<label for=\"direcclugar\">Direcci&oacute;n</label>\n");
      out.write("\t\t\t\t<input type=\"text\" maxlength = \"100\" size=\"50\" name=\"direcclugar\" title=\"Introduzca la direcci&oacute;n del lugar\">\n");
      out.write("\t\t\t</div><br/>\n");
      out.write("\t\t\t<div id=\"tadescrlugar\" style=\"float:left\">\n");
      out.write("\t\t\t\t<label for=\"descrlugar\">Descripci&oacute;n</label>\n");
      out.write("\t\t\t\t<div id=\"capadescripcionlugar\">\n");
      out.write("\t\t\t\t\t<textarea id=\"descrlugar\" name=\"descrlugar\" rows=\"4\" cols =\"45\" \n");
      out.write("\t\t\t\t\tonkeyup=\"contarCaracteres(this, event)\"  title=\"Introduzca la descripci&oacute;n del lugar\"></textarea>\t\t\t\t\t\n");
      out.write("\t\t\t\t</div>\n");
      out.write("\t\t\t\t<div id=\"capacontador\">\n");
      out.write("\t\t\t\t\t<input id=\"contador\" type=\"text\" size=\"4\" readonly value=\"255\"/>\n");
      out.write("\t\t\t\t\t<br><small>Max. 255 caracteres</small>\n");
      out.write("\t\t\t\t\t<p id=\"limitechar\"></p>\n");
      out.write("\t\t\t\t</div>\n");
      out.write("\t\t\t</div>\t\n");
      out.write("\t\t</div>\n");
      out.write("\t\t<div style=\"float:left; width: 100%\">\n");
      out.write("\t\t<div>\t\n");
      out.write("\t\t\t<h3>Tel&eacute;fonos</h3>\n");
      out.write("\t\t\t<input type=\"hidden\" id=\"numMaxTfnos\" name=\"numMaxTfnos\" value=\"1\" size=\"2\">\n");
      out.write("\t\t\t<input type=\"hidden\" id=\"numActualTfnos\" name=\"numActualTfnos\" value=\"1\" size=\"2\">\n");
      out.write("\t\t\t<div id=\"listatfnos\" >\n");
      out.write("\t\t\t\t<div id=\"btntelefonos\">\n");
      out.write("\t\t\t\t\t<button onclick=\"anadirTfno()\" title=\"A�adir otro telefono\">+</button>\n");
      out.write("\t\t\t\t\t<button id=\"btnborrtfno\" onclick=\"quitarTfno()\" title=\"Eliminar telefono\">-</button>\n");
      out.write("\t\t\t\t</div><br/>\n");
      out.write("\t\t\t\t<div class=\"divtfno\" id=\"divtfno1\">\n");
      out.write("\t\t\t\t\t<input type=\"hidden\" id=\"idtfno1\" name=\"idtfno1\" value=\"0\" size=\"2\">\n");
      out.write("\t\t\t\t\t<input type=\"checkbox\" id=\"tfnochk_1\" name=\"tfnochk_1\" class=\"chkbox\">\n");
      out.write("\t\t\t\t\t<input type=\"text\" id=\"tfno1\" name=\"tfno1\" value=\"\" maxlength=\"45\" title=\"Introduzca telefono\">\n");
      out.write("\t\t\t\t</div>\n");
      out.write("\t\t\t</div>\n");
      out.write("\t\t</div>\n");
      out.write("\t\t<br/>\n");
      out.write("\t\t<div align=\"center\">\n");
      out.write("\t\t\t<button id=\"btnEnvia\" class=\"temponoff\" title=\"Guardar nuevo lugar\"\n");
      out.write("\t\t\tonclick=\"deshabilitar(this.id); procesaParametros('res_insert_lugar', 'frmnuevolugar', 'proc_inserta_lugar.jsp', 'post')\">Guarda</button>\n");
      out.write("\t\t\t\t\t\t\t\t\n");
      out.write("\t\t\t<button id=\"btnCancelaCreacionLugar\" title=\"Cancelar\"\n");
      out.write("\t\t\tonclick=\"cancelaCreacionNuevoLugar()\">Cancelar</button>\n");
      out.write("\t\t\t\n");
      out.write("\t\t\t<button onclick=\"verArchivos()\">Ver archivos</button>\n");
      out.write("\t\t</div>\n");
      out.write("\t</div>\n");
      out.write("\t\t</form>\n");
      out.write("\t\t<br/>\n");
      out.write("\t</div>\n");
      out.write("\t<a name=\"link2form\"/>\n");
      out.write("\t<div id=\"res_insert_lugar\"></div>\n");
      out.write("\t<div id=\"map\" style=\"width: 750px; height: 380px; clear:both;\"></div>\n");
      out.write("\t</div>\n");
      org.apache.jasper.runtime.JspRuntimeLibrary.include(request, response, "pie.html", out, false);
      out.write('	');
      out.write('\n');
    } catch (Throwable t) {
      if (!(t instanceof SkipPageException)){
        out = _jspx_out;
        if (out != null && out.getBufferSize() != 0)
          try { out.clearBuffer(); } catch (java.io.IOException e) {}
        if (_jspx_page_context != null) _jspx_page_context.handlePageException(t);
      }
    } finally {
      _jspxFactory.releasePageContext(_jspx_page_context);
    }
  }
}
